<?php
class Matches {

    var $matches;

    function Matches() {
        $this->matches = array ();
    }

    function updateMatchRecord($matchRecordId, $comments) {
        for ($i = 0; $i < sizeof($this->matches); $i++) {
            if ($this->matches[$i]->homeRec->id == $matchRecordId) {
                $this->matches[$i]->homeRec->comments = $comments;
                return $this->matches[$i]->homeRec->update();
            } else
                if ($this->matches[$i]->awayRec->id == $matchRecordId) {
                    $this->matches[$i]->awayRec->comments = $comments;
                    return $this->matches[$i]->awayRec->update();
                }
        }
        return false;
    }

    function updateMatch(& $match) {
        for ($i = 0; $i < sizeof($this->matches); $i++) {
            if ($this->matches[$i]->id == $match->id) {
                $this->matches[$i] = $match;
            }
        }
    }

    function numMatches() {
        return sizeof($this->matches);
    }

    function getMatch($id) {
        foreach ($this->matches as $match) {
            if ($id == $match->id) {
                return $match;
            }
        }
        $md = new MatchDao();
        return $md->findMatch($id);
    }

}
?>